package com.sun.designpatternsdemo.bridge.bean

import android.util.Log

/**
 * 版权：xx公司 版权所有
 * @author sun
 * 版本：1.0
 * 创建日期：2021/7/1 14:26
 * 描述：实体类
 *创建桥接实现接口
 */
interface DrawAPI {
    fun drawCircle(radius: Int, x: Int, y: Int)
}

abstract class Shape(drawAPI: DrawAPI) {
    abstract fun draw()
}

class Circle(val x: Int, val y: Int, val radius: Int, val drawAPI: DrawAPI) : Shape(drawAPI) {
    override fun draw() {
        drawAPI.drawCircle(radius = radius, x = x, y = y)
    }
}

class GreenCircle : DrawAPI {
    override fun drawCircle(radius: Int, x: Int, y: Int) {
        Log.e(
            "---", "Drawing Circle[ color: green, radius: "
                    + radius + ", x: " + x + ", y: " + y + "]"
        )
    }

}

class RedCircle : DrawAPI {
    override fun drawCircle(radius: Int, x: Int, y: Int) {
        Log.e(
            "---", "Drawing Circle[ color: red, radius: "
                    + radius + ", x: " + x + ", y: " + y + "]"
        )
    }

}